package com.cxb.entity;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class GpsStack {

	List<Gps> list = new ArrayList<Gps>();

	public void addGps(Gps gps) {
		list.add(gps);
	}

	public void clear() {
		list.clear();
	}

	public Gps getBestGpsPoint() {
		if (list.size() < 1) {
			return null;
		}
		Collections.sort(list, new Comparator<Gps>() {

			@Override
			public int compare(Gps lhs, Gps rhs) {
				if (lhs.getScore() == rhs.getScore()) {
					return 0;
				}
				return lhs.getScore() > rhs.getScore() ? 1 : -1;
			}

		});
		return list.get(0);
	}
}
